home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
ICProgKit 1.3.sit
/
ICProgKit1.3
/
Goodies
/
ICeTEe
/
LowLevel.p
< prev
next >
Wrap
Text File
|
1992-11-05
|
5KB
|
227 lines
unit LowLevel;
(*
# Copyright Department of Computer Science
# University of Western Australia
# Created : Quinn
# Station : Eriodon
# Date : Monday, 4 November 1991
Really sleasy stuff that it not for the faint of heart.
*)
interface
{$ifc undefined THINK_Pascal}
uses
Types;
{$endc}
(* Global Bashing - Get constants from SysEqu.p *)
function GetGlobalSignedByte (ad: univ longint): SignedByte;
inline
$205F, (* move.l (sp)+,a0 *)
$1E90; (* move.b (a0),(sp) *)
procedure SetGlobalSignedByte (ad: univ longint; b: SignedByte); (* not univ cause I dont trust Pascal *)
inline
$205F, (* move.l (sp)+,a0 *)
$1097, (* move.b (sp),(a0) *)
$548F; (* addq.l #2,sp *)
(* I dont use autoincrement because I'm paranoid *)
function GetGlobalByte (ad: univ longint): integer;
inline
$205F, (* move.l (sp)+,a0 *)
$7000, (* moveq.l #0,d0 *)
$1010, (* move.b (a0),d0 *)
$3E80; (* move.w d0,(sp) *)
procedure SetGlobalByte (ad: univ longint; n: univ integer); (* integer for ease of use *)
inline
$301F, (* move.w (sp)+,d0 *)
$205F, (* move.l (sp)+,a0 *)
$1080; (* move.b d0,(a0) *)
function GetGlobalW (ad: univ longint): integer;
inline
$205F, (* move.l (sp)+,a0 *)
$3E90; (* move.w (a0),(sp) *)
procedure SetGlobalW (ad: univ longint; w: univ integer);
inline
$301F, (* move.w (sp)+,d0 *)
$205F, (* move.l (sp)+,a0 *)
$3080; (* move.w d0,(a0) *)
function GetGlobalL (ad: univ longint): longint;
inline
$205F, (* move.l (sp)+,a0 *)
$2E90; (* move.l (a0),(sp) *)
procedure SetGlobalL (ad: univ longint; l: univ longint);
inline
$201F, (* move.l (sp)+,d0 *)
$205F, (* move.l (sp)+,a0 *)
$2080; (* move.l d0,(a0) *)
function GetGlobalString (ad: univ longint): Str255;
procedure SetGlobalString (ad: univ longint; s: Str255); (* only bashes len+1 chars *)
(* Calling *)
procedure CallProcPtr (ad: univ ProcPtr);
inline
$205F, (* move.l (a7)+,a0 ; pop proc address *)
$4E90; (* jsr (a0) ; call proc *)
(* Pointer Arithmetic *)
function AddPtrLong (p: univ Ptr; offset: longint): Ptr;
inline
$201F, (* move.l (sp)+,d0 ; pop offset *)
$D09F, (* add.l (sp)+,d0 ; add ptr to offset (and pop p) *)
$2E80; (* move.l d0,(sp) ; place in result *)
procedure OffsetPtr (var p: univ Ptr; offset: longint);
inline
$201F, (* move.l (sp)+,d0 ; pop offset *)
$205F, (* move.l (sp)+,a0 ; pop address of p *)
$D190; (* add.l d0,(a0) ; add offset to p *)
function SubPtrPtr (leftp, rightp: univ Ptr): longint;
inline
$201F, (* move.l (sp)+,d0 ; pop rightp *)
$A055, (* _StripAddress ; strip if needed *)
$2200, (* move.l d0,d1 ; store in d1 *)
$201F, (* move.l (sp)+,d0 ; pop leftp *)
$A055, (* _StripAddress ; strip if needed (reg traps preserve d1) *)
$9081, (* sub.l d1,d0 ; d0 := leftp - rightp *)
$2E80; (* move.l d0,(sp) ; place result *)
(* Register Getting - Address *)
function GetRegA0: Ptr;
inline
$2E88; (* movea.l a0,(sp) ; fetch a0 into tos *)
function GetRegA1: Ptr;
inline
$2E89;
function GetRegA2: Ptr;
inline
$2E8A;
function GetRegA3: Ptr;
inline
$2E8B;
function GetRegA4: Ptr;
inline
$2E8C;
function GetRegA5: Ptr;
inline
$2E8D;
function GetRegA6: Ptr;
inline
$2E8E;
function GetRegA7: Ptr;
inline
$2E8F;
(* Register Setting - Address *)
procedure SetRegA0 (n: univ Ptr);
inline
$205F; (* movea.l (sp)+,a0 ; pop n into a0 *)
procedure SetRegA1 (n: univ Ptr);
inline
$225F;
procedure SetRegA2 (n: univ Ptr);
inline
$245F;
procedure SetRegA3 (n: univ Ptr);
inline
$265F;
procedure SetRegA4 (n: univ Ptr);
inline
$285F;
procedure SetRegA5 (n: univ Ptr);
inline
$2A5F;
procedure SetRegA6 (n: univ Ptr);
inline
$2C5F;
procedure SetRegA7 (n: univ Ptr);
inline
$2E5F;
(* Register Getting - Data *)
function GetRegD0: longint;
inline
$2E80; (* move.l d0,(sp) ; fetch d0 into tos *)
function GetRegD1: longint;
inline
$2E81;
function GetRegD2: longint;
inline
$2E82;
function GetRegD3: longint;
inline
$2E83;
function GetRegD4: longint;
inline
$2E84;
function GetRegD5: longint;
inline
$2E85;
function GetRegD6: longint;
inline
$2E86;
function GetRegD7: longint;
inline
$2E87;
(* Register Setting - Data *)
procedure SetRegD0 (n: univ longint);
inline
$201F; (* move.l (sp)+,(d0) ; pop n into d0 *)
procedure SetRegD1 (n: univ longint);
inline
$221F;
procedure SetRegD2 (n: univ longint);
inline
$241F;
procedure SetRegD3 (n: univ longint);
inline
$261F;
procedure SetRegD4 (n: univ longint);
inline
$281F;
procedure SetRegD5 (n: univ longint);
inline
$2A1F;
procedure SetRegD6 (n: univ longint);
inline
$2C1F;
procedure SetRegD7 (n: univ longint);
inline
$2E1F;
implementation
{$ifc undefined THINK_Pascal}
uses
Memory;
{$endc}
function GetGlobalString (ad: univ longint): Str255;
var
tmp: Str255;
begin
BlockMove(pointer(ad), @tmp, sizeof(tmp));
GetGlobalString := tmp;
end; (* GetGlobalB *)
procedure SetGlobalString (ad: univ longint; s: Str255); (* only bashes len+1 chars *)
begin
BlockMove(@s, pointer(ad), Length(s) + 1);
end; (* GetGlobalB *)
end. (* LowLevel *)